# -*- encoding:utf-8 -*-
# !/usr/bin/env python
'''
    python-0806-02.py
    ======================
    @descript: 递归案例
    @copyright:nnz
    @author:dln
    @date: 2021/8/9 12:12
    @version:v1.0
'''
#阶乘案例
def fun_01(param_01):
    v_result=0
    if param_01==1:
        v_result=1
    else:
        v_result=param_01*fun_01(param_01-1)   #写规律
    pass
    return v_result
v_rrsult01=fun_01(1)
v_rrsult02=fun_01(3)
print('1的阶乘为：',v_rrsult01)
print('3的阶乘为：',v_rrsult02)

#阶加
 #   n+f(n-1)

def fun_02(parm_02):
     result=0
     if parm_02==1:
         result=1
     else:
         v_rrsult02=parm_02+fun_02(parm_02-1)
         pass
     return result
v_rrsult03=fun_02(1)
v_rrsult04=fun_02(3)
print('1的阶加为：',v_rrsult03)
print('3的阶加为：',v_rrsult04)
#斐波那契数列
def fun_03(param_01):
    v_rrsult=0
    if param_01==1 or param_01==2:
      v_rrsult=1
    else:
        v_rrsult=fun_03(param_01-1)+fun_03(param_01-2)
        pass
    return v_rrsult
v_rrsult05=fun_03(1)
v_rrsult06=fun_03(2)
v_rrsult07=fun_03(7)
print(v_rrsult05)
print(v_rrsult06)
print(v_rrsult07)
#获取整数 7869每一位的值
def fun_04(p_01):
    if p_01<10:
       print(p_01)
    else:
        print(p_01%10)
        fun_04(p_01//10)
        pass
    pass
fun_04(7869)

def fun_02(p_01):
    if p_01<10:
        print(p_01)
    else:
      print(p_01%10)
      fun_02(p_01//10)
      pass
    pass
fun_02(68495)
'''
v_list=list[]
v_list01[1,2,3]
'''
def fun_05(p_list,p_start,p_end,v_restul:list):
    if p_start-p_end==1:
        v_restul.append(p_list[p_start])
    else:
        v_restul.append(p_list[p_start])
        fun_05(p_list,p_start+1,p_end,v_restul)
        pass
    pass
v_result08=[]
v_list=[1,2,3,4,5,6,7,8,9]
fun_05(v_list,v_result08)
print(v_result08)
